home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume23 / sps2 / part04 < prev    next >
Encoding:
Internet Message Format  |  1991-01-08  |  10.2 KB

  1. Subject:  v23i050:  SPS, a PS replacement, Part04/04
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: be5fef91 d35a2c1e adaa82d0 d7126779
  5.  
  6. Submitted-by: Robert Ward <olsen!robert@uunet.uu.net>
  7. Posting-number: Volume 23, Issue 50
  8. Archive-name: sps2/part04
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then feed it
  12. # into a shell via "sh file" or similar.  To overwrite existing files,
  13. # type "sh file -c".
  14. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  15. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  16. # Contents:  Make.4.1 Make.4.2 Make.4.3 prcmd.c prheader.c printall.c
  17. #   prsummary.c selecttty.c
  18. # Wrapped by rsalz@papaya.bbn.com on Mon Nov 26 14:03:25 1990
  19. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  20. echo If this archive is complete, you will see the following message:
  21. echo '          "shar: End of archive 4 (of 4)."'
  22. if test -f 'Make.4.1' -a "${1}" != "-c" ; then 
  23.   echo shar: Will not clobber existing file \"'Make.4.1'\"
  24. else
  25.   echo shar: Extracting \"'Make.4.1'\" \(882 characters\)
  26.   sed "s/^X//" >'Make.4.1' <<'END_OF_FILE'
  27. X# Makefile for SPS (4.1BSD UNIX Version)
  28. X
  29. XPROG    =       sps
  30. XOBJS    =       filecount.o findtty.o flagdecode.o flagsetup.o \
  31. X        getcmd.o getupage.o globals1.o globals2.o hashuid.o \
  32. X        initialise.o initsymbols.o inittty.o main.o mktree.o \
  33. X        needed.o openfiles.o percentmem.o prcmd.o prcpu.o \
  34. X        prheader.o printall.o printproc.o prsummary.o readstatus.o \
  35. X        selectproc.o selecttty.o termwidth.o ttystatus.o waitingfor.o
  36. X
  37. XINCS    =       sps.h
  38. XLIBS    =       -ltermlib
  39. XCFLAGS  =       -I/usr/src/sys -DCHAOS
  40. X
  41. Xall:            $(PROG)
  42. X.c.o:
  43. X        cc $(CFLAGS) -c -O -R $<
  44. Xglobals1.o waitingfor.o:
  45. X        cc $(CFLAGS) -c -O $<
  46. X
  47. X$(OBJS):        $(INCS)
  48. X
  49. X$(PROG):        $(OBJS)
  50. X        cc -o $@ $(OBJS) $(LIBS)
  51. X
  52. Xinstall:        $(PROG)
  53. X        strip $(PROG)
  54. X        mv $(PROG) /bin/$(PROG)
  55. X        /etc/chown root /bin/$(PROG)
  56. X        chmod 4711 /bin/$(PROG)
  57. X
  58. Xlint:
  59. X        lint -x -b $(CFLAGS) *.c
  60. Xclean:
  61. X        rm -f $(OBJS) $(PROG)
  62. END_OF_FILE
  63.   if test 882 -ne `wc -c <'Make.4.1'`; then
  64.     echo shar: \"'Make.4.1'\" unpacked with wrong size!
  65.   fi
  66.   # end of 'Make.4.1'
  67. fi
  68. if test -f 'Make.4.2' -a "${1}" != "-c" ; then 
  69.   echo shar: Will not clobber existing file \"'Make.4.2'\"
  70. else
  71.   echo shar: Extracting \"'Make.4.2'\" \(977 characters\)
  72.   sed "s/^X//" >'Make.4.2' <<'END_OF_FILE'
  73. X# Makefile for SPS (Vax 4.2BSD and Ultrix1.2 UNIX Version)
  74. X
  75. XPROG    =       sps
  76. XOBJS    =       filecount.o findtty.o flagdecode.o flagsetup.o \
  77. X        getcmd.o getupage.o globals1.o globals2.o hashuid.o \
  78. X        initialise.o initsymbols.o inittty.o main.o mktree.o \
  79. X        needed.o openfiles.o percentmem.o prcmd.o prcpu.o \
  80. X        prheader.o printall.o printproc.o prsummary.o readstatus.o \
  81. X        selectproc.o selecttty.o termwidth.o ttystatus.o waitingfor.o
  82. XINCS    =       sps.h
  83. XCC      =       cc
  84. XCFLAGS  =       -DBSD42 -I/sys
  85. XLIBS    =       -ltermlib
  86. XDIRINSTALL =    /bin
  87. X
  88. Xall:            $(PROG)
  89. X.c.o:
  90. X        $(CC) $(CFLAGS) -c -O -R $<
  91. X    
  92. Xglobals1.o waitingfor.o:
  93. X        $(CC) $(CFLAGS) -c -O $<
  94. X
  95. X$(OBJS):        $(INCS)
  96. X
  97. X$(PROG):        $(OBJS)
  98. X        $(CC) -o $@ $(OBJS) $(LIBS)
  99. X
  100. Xinstall:        $(PROG)
  101. X        strip $(PROG)
  102. X        mv $(PROG) $(DIRINSTALL)/$(PROG)
  103. X        /etc/chown root $(DIRINSTALL)/$(PROG)
  104. X        chgrp kmem $(DIRINSTALL)/$(PROG)
  105. X        chmod 2755 $(DIRINSTALL)/$(PROG)
  106. X
  107. Xlint:
  108. X        lint -x -b $(CFLAGS) *.c
  109. Xclean:
  110. X        rm -f $(OBJS) $(PROG)
  111. END_OF_FILE
  112.   if test 977 -ne `wc -c <'Make.4.2'`; then
  113.     echo shar: \"'Make.4.2'\" unpacked with wrong size!
  114.   fi
  115.   # end of 'Make.4.2'
  116. fi
  117. if test -f 'Make.4.3' -a "${1}" != "-c" ; then 
  118.   echo shar: Will not clobber existing file \"'Make.4.3'\"
  119. else
  120.   echo shar: Extracting \"'Make.4.3'\" \(966 characters\)
  121.   sed "s/^X//" >'Make.4.3' <<'END_OF_FILE'
  122. X# Makefile for SPS (Vax 4.3BSD Version)
  123. X
  124. XPROG    =       sps
  125. XOBJS    =       filecount.o findtty.o flagdecode.o flagsetup.o \
  126. X        getcmd.o getupage.o globals1.o globals2.o hashuid.o \
  127. X        initialise.o initsymbols.o inittty.o main.o mktree.o \
  128. X        needed.o openfiles.o percentmem.o prcmd.o prcpu.o \
  129. X        prheader.o printall.o printproc.o prsummary.o readstatus.o \
  130. X        selectproc.o selecttty.o termwidth.o ttystatus.o waitingfor.o
  131. XINCS    =       sps.h
  132. XCC      =       cc
  133. XCFLAGS  =       -DBSD42 -DBSD43 -I/sys
  134. XLIBS    =       -ltermlib
  135. XDIRINSTALL =    /bin
  136. X
  137. Xall:            $(PROG)
  138. X.c.o:
  139. X        $(CC) $(CFLAGS) -c -O -R $<
  140. X    
  141. Xglobals1.o waitingfor.o:
  142. X        $(CC) $(CFLAGS) -c -O $<
  143. X
  144. X$(OBJS):        $(INCS)
  145. X
  146. X$(PROG):        $(OBJS)
  147. X        $(CC) -o $@ $(OBJS) $(LIBS)
  148. X
  149. Xinstall:        $(PROG)
  150. X        strip $(PROG)
  151. X        mv $(PROG) $(DIRINSTALL)/$(PROG)
  152. X        /etc/chown root $(DIRINSTALL)/$(PROG)
  153. X        chgrp kmem $(DIRINSTALL)/$(PROG)
  154. X        chmod 2755 $(DIRINSTALL)/$(PROG)
  155. X
  156. Xlint:
  157. X        lint -x -b $(CFLAGS) *.c
  158. Xclean:
  159. X        rm -f $(OBJS) $(PROG)
  160. END_OF_FILE
  161.   if test 966 -ne `wc -c <'Make.4.3'`; then
  162.     echo shar: \"'Make.4.3'\" unpacked with wrong size!
  163.   fi
  164.   # end of 'Make.4.3'
  165. fi
  166. if test -f 'prcmd.c' -a "${1}" != "-c" ; then 
  167.   echo shar: Will not clobber existing file \"'prcmd.c'\"
  168. else
  169.   echo shar: Extracting \"'prcmd.c'\" \(785 characters\)
  170.   sed "s/^X//" >'prcmd.c' <<'END_OF_FILE'
  171. X# ifndef lint
  172. Xstatic char SccsId[] =  "@(#)prcmd.c    1.1\t10/1/88" ;
  173. X# endif
  174. X
  175. X# include       "sps.h"
  176. X# include       "flags.h"
  177. X
  178. X/* PRCMD - Prints the command arguments according to the switches */
  179. Xprcmd ( p, lpad, width )
  180. X
  181. Xregister struct process         *p ;
  182. Xint                             lpad ;
  183. Xint                             width ;
  184. X
  185. X{
  186. X    extern struct flags     Flg ;
  187. X    extern unsigned         Termwidth ;
  188. X
  189. X    printf( "%*d ", lpad, p->pr_p.p_pid ) ;
  190. X    if ( Flg.flg_f )
  191. X    {
  192. X        printf( "%5d ", p->pr_p.p_ppid ) ;
  193. X        width -= 6 ;
  194. X    }
  195. X    if ( Flg.flg_g )
  196. X    {
  197. X        printf( "%5d ", p->pr_p.p_pgrp ) ;
  198. X        width -= 6 ;
  199. X    }
  200. X    width += Termwidth ;
  201. X    if ( Flg.flg_w )
  202. X        printf( "%s\n", p->pr_cmd ) ;
  203. X    else if ( width > 0 )
  204. X        printf( "%-.*s\n", width, p->pr_cmd ) ;
  205. X    if ( p->pr_csaved )
  206. X        free( p->pr_cmd ) ;
  207. X}
  208. END_OF_FILE
  209.   if test 785 -ne `wc -c <'prcmd.c'`; then
  210.     echo shar: \"'prcmd.c'\" unpacked with wrong size!
  211.   fi
  212.   # end of 'prcmd.c'
  213. fi
  214. if test -f 'prheader.c' -a "${1}" != "-c" ; then 
  215.   echo shar: Will not clobber existing file \"'prheader.c'\"
  216. else
  217.   echo shar: Extracting \"'prheader.c'\" \(683 characters\)
  218.   sed "s/^X//" >'prheader.c' <<'END_OF_FILE'
  219. X# ifndef lint
  220. Xstatic char SccsId[] =  "@(#)prheader.c    1.1\t10/1/88" ;
  221. X# endif
  222. X
  223. X# include       "sps.h"
  224. X# include       "flags.h"
  225. X
  226. X/* PRHEADER - Print a header according to the switches */
  227. Xprheader ()
  228. X{
  229. X    extern struct flags     Flg ;
  230. X
  231. X    printf( "Ty User    %s Proc#", Flg.flg_v ?
  232. X# ifdef SUNOS40
  233. X# ifdef OLDSTATS
  234. X        " Status Fl Nice Virt Res %M  Time Child %C" :
  235. X# else
  236. X        " Status Fl Nice Prv  Shr  Res %M  Time Child %C" :
  237. X# endif
  238. X# else
  239. X        " Status Fl Nice Virtual Resident %M  Time Child %C" :
  240. X# endif
  241. X        Flg.flg_d ?
  242. X        "  Files    PageFaults Swap BlockI/O Kbytsecs" : "" ) ;
  243. X    if ( Flg.flg_f )
  244. X        printf( " Ppid#" ) ;
  245. X    if ( Flg.flg_g )
  246. X        printf( " Pgrp#" ) ;
  247. X    printf( " Command\n" ) ;
  248. X}
  249. END_OF_FILE
  250.   if test 683 -ne `wc -c <'prheader.c'`; then
  251.     echo shar: \"'prheader.c'\" unpacked with wrong size!
  252.   fi
  253.   # end of 'prheader.c'
  254. fi
  255. if test -f 'printall.c' -a "${1}" != "-c" ; then 
  256.   echo shar: Will not clobber existing file \"'printall.c'\"
  257. else
  258.   echo shar: Extracting \"'printall.c'\" \(509 characters\)
  259.   sed "s/^X//" >'printall.c' <<'END_OF_FILE'
  260. X# ifndef lint
  261. Xstatic char SccsId[] =  "@(#)printall.c    1.1\t10/1/88" ;
  262. X# endif
  263. X
  264. X# include       <stdio.h>
  265. X# include       "sps.h"
  266. X
  267. X/* PRINTALL - Recursively print the process tree. */
  268. Xprintall ( p, md )
  269. X
  270. Xregister struct process         *p ;
  271. Xregister int                    md ;
  272. X
  273. X{
  274. X    while ( p )
  275. X    {       /* Print this process */
  276. X        printproc( p, md ) ;    
  277. X        (void)fflush( stdout ) ;
  278. X        /* Print child processes */
  279. X        printall( p->pr_child, md+1 ) ;
  280. X        /* Print brother processes */
  281. X        p = p->pr_sibling ;     
  282. X    }
  283. X}
  284. END_OF_FILE
  285.   if test 509 -ne `wc -c <'printall.c'`; then
  286.     echo shar: \"'printall.c'\" unpacked with wrong size!
  287.   fi
  288.   # end of 'printall.c'
  289. fi
  290. if test -f 'prsummary.c' -a "${1}" != "-c" ; then 
  291.   echo shar: Will not clobber existing file \"'prsummary.c'\"
  292. else
  293.   echo shar: Extracting \"'prsummary.c'\" \(712 characters\)
  294.   sed "s/^X//" >'prsummary.c' <<'END_OF_FILE'
  295. X# ifndef lint
  296. Xstatic char SccsId[] =  "@(#)prsummary.c    1.1\t10/1/88" ;
  297. X# endif
  298. X
  299. X# include       "sps.h"
  300. X
  301. X/* PRSUMMARY - Print the summarising information */
  302. Xprsummary ()
  303. X{
  304. X    extern struct summary   Summary ;
  305. X
  306. X    printf(
  307. X"%D (%Dk) processes, %D (%Dk) busy, %D (%Dk) loaded, %D (%Dk) swapped\n",
  308. X        Summary.sm_ntotal, KBYTES( Summary.sm_ktotal ),
  309. X        Summary.sm_nbusy, KBYTES( Summary.sm_kbusy ),
  310. X        Summary.sm_nloaded, KBYTES( Summary.sm_kloaded ),
  311. X        Summary.sm_nswapped, KBYTES( Summary.sm_kswapped ) ) ;
  312. X    Summary.sm_ntotal = 0L ;
  313. X    Summary.sm_ktotal = 0L ;
  314. X    Summary.sm_nbusy = 0L ;
  315. X    Summary.sm_kbusy = 0L ;
  316. X    Summary.sm_nloaded = 0L ;
  317. X    Summary.sm_kloaded = 0L ;
  318. X    Summary.sm_nswapped = 0L ;
  319. X    Summary.sm_kswapped = 0L ;
  320. X}
  321. END_OF_FILE
  322.   if test 712 -ne `wc -c <'prsummary.c'`; then
  323.     echo shar: \"'prsummary.c'\" unpacked with wrong size!
  324.   fi
  325.   # end of 'prsummary.c'
  326. fi
  327. if test -f 'selecttty.c' -a "${1}" != "-c" ; then 
  328.   echo shar: Will not clobber existing file \"'selecttty.c'\"
  329. else
  330.   echo shar: Extracting \"'selecttty.c'\" \(448 characters\)
  331.   sed "s/^X//" >'selecttty.c' <<'END_OF_FILE'
  332. X# ifndef lint
  333. Xstatic char SccsId[] =  "@(#)selecttty.c    1.1\t10/1/88" ;
  334. X# endif
  335. X
  336. X# include       "sps.h"
  337. X# include       "flags.h"
  338. X
  339. X/* SELECTTTY - Decides whether this process is interesting for its tty */
  340. Xselecttty ( p )
  341. X
  342. Xregister struct process         *p ;
  343. X
  344. X{
  345. X    register union flaglist *fp ;
  346. X    extern struct flags     Flg ;
  347. X
  348. X    for ( fp = Flg.flg_Tlist ; fp->f_ttyline ; fp++ )
  349. X        if ( fp->f_ttyline == p->pr_tty )
  350. X            return ( 1 ) ;
  351. X    return ( 0 ) ;
  352. X}
  353. END_OF_FILE
  354.   if test 448 -ne `wc -c <'selecttty.c'`; then
  355.     echo shar: \"'selecttty.c'\" unpacked with wrong size!
  356.   fi
  357.   # end of 'selecttty.c'
  358. fi
  359. echo shar: End of archive 4 \(of 4\).
  360. cp /dev/null ark4isdone
  361. MISSING=""
  362. for I in 1 2 3 4 ; do
  363.     if test ! -f ark${I}isdone ; then
  364.     MISSING="${MISSING} ${I}"
  365.     fi
  366. done
  367. if test "${MISSING}" = "" ; then
  368.     echo You have unpacked all 4 archives.
  369.     rm -f ark[1-9]isdone
  370. else
  371.     echo You still must unpack the following archives:
  372.     echo "        " ${MISSING}
  373. fi
  374. exit 0
  375. exit 0 # Just in case...
  376.